<extend name='Public/_Main' />
<block name='title'>
    <title>权限配置</title>
</block>
<block name='right'>
    <form action="{:U('group_access')}" method='post'>
        <!--权限结构-->
        <foreach name='list.role' item='role'>
            <div class="panel panel-default level-1">
                <div class="panel-heading">
                    <h3 class="panel-title">
                    <label level="1">
                        <input type="checkbox" value="{$role.id}" name='roleid[]' {$role[ 'checked']?$role[ 'checked']:$role[ 'checked']}> {$role.title}
                        <span class='auth_color'>[{$role.name}]</span>
                    </label>
            </h3>
                </div>
                <div class="panel-body">
                    <!--leve2-->
                    <foreach name='role.child' item='child'>
                        <div class="panel panel-success level-2">
                            <div class="panel-heading">
                                <h3 class="panel-title">
                        <label level='2'>
                            <input type="checkbox" value="{$child.id}" name='roleid[]' {$child[ 'checked']?$child[ 'checked']:$child[ 'checked']}> {$child.title}
                            <span class='auth_color'>[{$child.name}]</span>
                        </label>
                            </h3>
                            </div>
                            <div class="panel-body">
                                <!--leve3-->
                                <foreach name='child.child' item='child3'>
                                    <div class="panel panel-info level-3">
                                        <div class="panel-heading">
                                            <h3 class="panel-title">
                                    <label level='3' style='margin-bottom:0px'>
                                        <input type="checkbox" value="{$child3.id}" name='roleid[]' {$child3[ 'checked']?$child3[ 'checked']:$child3[ 'checked']}> {$child3.title}
                                        <span class='auth_color'>[{$child3.name}]</span>
                                    </label>
                                        </h3>
                                        </div>
                                        <div class="panel-body">
                                            <volist name="child3.child" id="vo">
                                                <label class='child_model'>
                                                    <input type="checkbox" value="{$vo.id}" name='roleid[]' {$vo[ 'checked']?$vo[ 'checked']:$vo[ 'checked']}> {$vo.title}
                                                </label>
                                            </volist>
                                        </div>
                                    </div>
                                </foreach>
                                <!--leve3-->
                            </div>
                        </div>
                    </foreach>
                    <!--end leve2-->
                </div>
            </div>
        </foreach>
        <!--//权限结构-->
        <input type='hidden' name='id' value='{$Think.get.id}'>
        <div class='col-xs-6'>
            <button class="btn btn-lg btn-primary btn-block" type="submit">保存配置</button>
        </div>
        <div class='col-xs-6'>
            <button class="btn btn-lg btn-default btn-block" type="button" onclick="javascript:history.back(-1);">返回</button>
        </div>
    </form>
</block>
<block name='javascript'>
    <script type="text/javascript">
    var group_access = "{:U('group_access')}";
    </script>
</block>
<block name='script'>
    <script src="__PUBLIC__/Jquery/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
    GroupAccess("label[level='1']", '.level-1');
    GroupAccess("label[level='2']", '.level-2');
    GroupAccess("label[level='3']", '.level-3');
    //权限勾选子项效果
    function GroupAccess(objclass, parent_child) {
        $(objclass).click(function() {
            var parent_input = $(this).parents(parent_child).find('input');
            parent_input.attr('checked') ? parent_input.attr('checked', 'checked') : parent_input.removeAttr('checked');
        });

    }
    </script>
</block>
